package com.owulia.leetcode.num.queue;

public class CircularQueue {
    private int[] array;
    private int tail = 0;
    private int head = 0;

    public CircularQueue(int ca) {
        if (ca <= 3) {
            ca = 10;
        }
        array = new int[ca];
    }


    public boolean inQu(int value) {
        int newTail = (tail + 1) % array.length;
        if (newTail == head) {
            return false;
        }
        array[tail] = value;
        tail = newTail;
        return true;
    }

    public int outQue() {
        if (tail == head) {
            return Integer.MIN_VALUE;
        }
        int res = array[head];
        head = (head + 1) % array.length;
        return res;
    }

}